$(function () {
	$('.layui-form').on('submit', function (e) {
		e.preventDefault();

		$.ajax({
			url: '/api/login',
			method: 'POST',
			data: $(this).serialize(),
			success: function (res) {
				if (res.status !== 0) {
					return layer.msg(res.message);
				}

				layer.msg('登录成功!');

				localStorage.setItem('token', res.token);

				location.href = './index.html';
			},
		});
	});
});
